//
//  Session.swift
//  app_rn_frontend
//
//  Created by 鱼涛 on 2017/12/14.
//  Copyright © 2017年 Facebook. All rights reserved.
//

import Foundation
import WCDBSwift

final class Session: TableCodable {
  
  static let table = "session"

  var id:Int = 0
  var sessionServerId:Int = 0
  var chatType:ChatType = .p2p
  var name:String? = nil
  var top:Bool = false
  var updatedDatetime:String? = nil
  var createdDatetime:String? = nil
  var deleted:Int = 0
  var seq:Int = 99

  enum CodingKeys: String, CodingTableKey {
    typealias Root = Session
//    static let objectRelationalMapping = TableBinding(CodingKeys.self)
    case id
    case sessionServerId = "session_server_id"
    case chatType = "chat_type"
    case name
    case top
    case updatedDatetime = "updated_datetime"
    case createdDatetime = "created_datetime"
    case deleted
    case seq
      
      static let objectRelationalMapping = TableBinding(CodingKeys.self) {
          BindColumnConstraint(.id, isPrimary: true, isAutoIncrement: true)
          BindColumnConstraint(.top, defaultTo: false)
      }

//    static var columnConstraintBindings: [CodingKeys: ColumnConstraintBinding]? {
//      return [.id: ColumnConstraintBinding(isPrimary: true, isAutoIncrement: true),
//              .top:ColumnConstraintBinding(defaultTo: false)]
//    }
  }


  var isAutoIncrement: Bool = true
  var lastInsertedRowID: Int = 0
}
